import QtQuick 2.0
import QtQuick.Controls 2.3

Item {
    id: root
    width: 850
    height: 580*0.85
    property alias titleText: title.text
    property real minSize:  Math.min(width/850, height/(580*0.85))

    signal qmlSN_sqlWriteFinish()
    onQmlSN_sqlWriteFinish: {
        gaugeStatorV.circularGaugeValue =  0.01*$sqlMcRecorder.qml_getRecordVal_bystr_toint16("B套机端电压")
        gaugeRotorC.circularGaugeValue = 0.01*$sqlMcRecorder.qml_getRecordVal_bystr_toint16("B套励磁电流")
        gaugeStatorV.text_value = $sqlMcRecorder.qml_getRecordVal_bystr_toint16("B套机端电压")*0.0001
                *$sqlMcRecorder.qml_getFactor("stator_voltage")
        gaugeRotorC.text_value = $sqlMcRecorder.qml_getRecordVal_bystr_toint16("B套励磁电流")*0.0001
                *$sqlMcRecorder.qml_getFactor("exc_current")

        if($sqlMcRecorder.qml_getBitBool("B套","调节器状态","恒控制角模式")===true) rb_staticSingal.checked = true;
        else rb_staticSingal.checked = false;
        if($sqlMcRecorder.qml_getBitBool("B套","调节器状态","正常模式")===true) rb_normalMode.checked = true;
        else rb_normalMode.checked = false;
        if($sqlMcRecorder.qml_getBitBool("B套","调节器状态","逆变")===true) rb_stopCommand.checked = true;
        else rb_stopCommand.checked = false;
        if($sqlMcRecorder.qml_getBitBool("B套","调节器状态","系统正在起励")===true) rb_startCommand.checked = true;
        else rb_startCommand.checked = false;

        progressBar.value = $sqlMcRecorder.qml_getRecordVal_bystr_toint16("B套控制信号")*180/10000
    }

    EXC_Gauge3 {
        id: gaugeStatorV
        x: 28*root.minSize
        y: 8*root.minSize
        width: 200*root.minSize
        height: 300*root.minSize
        element_cnmsgText: qsTr("定子电压")
        element_numsizeText: "V"
        element_tipText: "Ug(%)"
    }
    EXC_Gauge3 {
        id: gaugeRotorC
        x: 270*root.minSize
        y: 8*root.minSize
        width: 200*root.minSize
        height: 300*root.minSize
        element_cnmsgText: qsTr("励磁电流")
        element_numsizeText: "A"
        element_tipText: "If(%)"

    }
    ProgressBar {
        id: progressBar
        y: 450*root.minSize
        width: 425*root.minSize
        height: 25*root.minSize
        anchors.horizontalCenterOffset: 90*root.minSize
        anchors.horizontalCenter: parent.horizontalCenter
        to: 180
        value: 83.33
        background: Rectangle {
            implicitWidth: parent.width
            implicitHeight: parent.height
            color: "#e6e6e6"
            radius: 12*root.minSize
        }

        contentItem: Item {
            implicitWidth: parent.width
            implicitHeight: parent.height

            Rectangle {
                width: parent.parent.visualPosition * parent.width
                height: parent.height*0.8
                radius: 10*root.minSize
                anchors.verticalCenter: parent.verticalCenter
                color: "#17a81a"
            }


        }
    }
    Text {
        color: "#44fdfd"
        text: progressBar.value.toFixed(1)+"° "
        anchors.verticalCenterOffset: 0
        anchors.leftMargin: 23*root.minSize
        font.pixelSize: 30*root.minSize
        anchors.left: progressBar.right
        anchors.verticalCenter: progressBar.verticalCenter
    }

    Text {
        color: "#44fdfd"
        text: qsTr("A通道触发角度")
        font.pixelSize: 30*root.minSize
        anchors.right: progressBar.left
        anchors.rightMargin: parent.width/20
        anchors.verticalCenter: progressBar.verticalCenter
        font.family: "Verdana"
        font.bold: true
    }

    EXC_Normal_CheckBoxSytle {
        id: rb_staticSingal
        x: 51*root.minSize
        y: 327*root.minSize
        text: qsTr("恒控制角模式")
        textSize: 22*root.minSize
    }

    EXC_Normal_CheckBoxSytle {
        id: rb_normalMode
        x: 55*root.minSize
        y: 385*root.minSize
        text: qsTr("正常模式")
        textSize: 22*root.minSize
    }

    EXC_Normal_CheckBoxSytle {
        id: rb_stopCommand
        x: 301*root.minSize
        y: 327*root.minSize
        text: qsTr("停机令")
        textSize: 22*root.minSize
    }

    EXC_Normal_CheckBoxSytle {
        id: rb_startCommand
        x: 301*root.minSize
        y: 385*root.minSize
        text: qsTr("A通道开机")
        textSize: 22*root.minSize
    }

    Rectangle {
        id: columnLayoutA
        y: 77*root.minSize
        width: 317*root.minSize
        height: 352*root.minSize
        color: "#6692e8bc"
        radius: 10
        anchors.horizontalCenterOffset: 244
        anchors.horizontalCenter: parent.horizontalCenter

        EXC_Normal_BtnUncheckSecret_highStyle {
            x: 26*root.minSize
            y: 17*root.minSize
            width: 270*root.minSize
            height: 70*root.minSize
            nameText: qsTr("进入恒控制角模式")
            nameFontpixelSize: 27

            onClicked:{
                var t = $sqlMcDefine.qml_queryTableOnce(
                            'SELECT dec FROM reg_define WHERE define='+'\'切换到恒控制角模式\'')
                t = parseInt(4000, 16)+Number(t)
                $modbusInterface.sl_modbusWriteImpulse(t)
            }
        }

        EXC_Normal_BtnUncheckSecret_highStyle {
            x: 26*root.minSize
            y: 100*root.minSize
            width: 270*root.minSize
            height: 70*root.minSize
            nameText: qsTr("退出恒控制角模式")
            nameFontpixelSize: 27
            onClicked:{
                var t = $sqlMcDefine.qml_queryTableOnce(
                            'SELECT dec FROM reg_define WHERE define='+'\'切换到正常模式\'')
                t = parseInt(4000, 16)+Number(t)
                $modbusInterface.sl_modbusWriteImpulse(t)
            }
        }

        EXC_Normal_BtnUncheckSecret_highStyle {
            x: 28*root.minSize
            y: 190*root.minSize
            width: 130*root.minSize
            height: 70*root.minSize
            nameText: qsTr("开机")
            nameFontpixelSize: 30
            onClicked:{
                var t = $sqlMcDefine.qml_queryTableOnce(
                            'SELECT dec FROM reg_define WHERE define='+'\'开机令\'')
                t = parseInt(4000, 16)+Number(t)
                $modbusInterface.sl_modbusWriteImpulse(t)
            }
        }

        EXC_Normal_BtnUncheckSecret_highStyle {
            x: 166*root.minSize
            y: 190*root.minSize
            width: 130*root.minSize
            height: 70*root.minSize
            nameText: qsTr("停机")
            nameFontpixelSize: 30
            onClicked:{
                var t = $sqlMcDefine.qml_queryTableOnce(
                            'SELECT dec FROM reg_define WHERE define='+'\'停机令\'')
                t = parseInt(4000, 16)+Number(t)
                $modbusInterface.sl_modbusWriteImpulse(t)
            }
        }

        EXC_Normal_BtnUncheckSecret_highStyle {
            x: 73*root.minSize
            y: 270*root.minSize
            width: 170*root.minSize
            height: 70*root.minSize
            nameText: qsTr("退出停机")
            nameFontpixelSize: 30
            onClicked:{
                var t = $sqlMcDefine.qml_queryTableOnce(
                            'SELECT dec FROM reg_define WHERE define='+'\'停机令复归\'')
                t = parseInt(4000, 16)+Number(t)
                $modbusInterface.sl_modbusWriteImpulse(t)
            }
        }
    }

    Text {
        id: title
        y: 8*root.minSize
        text: qsTr("B通道小电流试验")
        anchors.horizontalCenterOffset: 258
        anchors.horizontalCenter: parent.horizontalCenter
        color: "#44fdfd"
        font.pixelSize: 30
        font.family: "Verdana"
        font.bold: true
    }
}

/*##^##
Designer {
    D{i:1;anchors_width:141.66666666666666}D{i:7;anchors_height:417.6;anchors_width:382.5}
D{i:14;anchors_height:44.37;anchors_width:127.5}D{i:15;anchors_height:44.37;anchors_width:127.5}
D{i:16;anchors_height:44.37;anchors_width:127.5}D{i:17;anchors_height:44.37;anchors_width:127.5}
D{i:18;anchors_height:44.37;anchors_width:127.5}
}
##^##*/
